<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>vue2 自定义指令 测试 focus</title>
</head>

<body>
  <div id="app">
    <input type="text" v-focus>
  </div>
  <script src="js/vue.js"></script>
  <script>
    Vue.directive('focus', {
      bind(el, binding, vnode) {
        console.log('bind');
      },
      inserted(el, binding, vnode) {
        console.log('inserted');
        el.focus()
      }
    });
    const app = new Vue({
      el: "#app",

    })
  </script>
</body>

</html>